<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>当前位置</title>
	<script src="./pdf/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="./js/lodash.js"></script>
	<script src="https://webapi.amap.com/maps?v=1.4.15&key=92bfa8b848fb3fbaf2b4d5fa40447225"></script>
</head>
<body>
	<div id="container" class="map"></div>
</body>
<style>
	html,body{
		margin: 0;
		padding: 0;
	}
	.map{
		width: 100%;
		height:250px;
		position: fixed;
		top: 0px;
	}
</style>
 <!-- <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script> -->
<script type="text/javascript" src="./js/uni.webview.1.5.2.js"></script>
<script>
		var map = new AMap.Map('container',{
			zoom: 16, //设置地图的缩放级别
			zoomEnable: false,
			dragEnable: false,
			touchZoom: false,
		});
		
		AMap.plugin('AMap.Geolocation', function() {
		  var geolocation = new AMap.Geolocation({
		    // 是否使用高精度定位，默认：true
		    enableHighAccuracy: true,
		    // 设置定位超时时间，默认：无穷大
		    timeout: 10000,
		  })
		
		  geolocation.getCurrentPosition()
		  AMap.event.addListener(geolocation, 'complete', onComplete)
		  AMap.event.addListener(geolocation, 'error', onError)
		
		  function onComplete (data) {
			  console.log(data)
		    // data是具体的定位信息
			var addressDesc = {
				lng: data.position.lng,
				lat: data.position.lat,
				name: data.formattedAddress,
			}
			uni.postMessage({
			    data: addressDesc
			});
		  }
		
		  function onError (data) {
		    // 定位出错
		  }
		})
</script>
</html>